package magic.deckbuilder.createDeck;

import magic.deckbuilder.DeckBuilderException;
import magic.deckbuilder.MagicDeckDB;
import magic.deckbuilder.modifyDeck.ModifyDeckActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class ValidateCreateDeckListener implements OnClickListener {
	
	private CreateDeckActivity activity;
	
	ValidateCreateDeckListener(CreateDeckActivity activity) {
		this.activity = activity;
	}

	@Override
	public void onClick(View v) {
		// TODO : Check what view is it, need to get 
		String tag = activity.tag.getText().toString();
		String resume = activity.resume.getText().toString();
		try {
			// Save deck in database
			MagicDeckDB mdbd = new MagicDeckDB(activity);
			long id = mdbd.createDeck(tag, resume);
			// Lauch the modify deck activity4
			Toast.makeText(activity, "id add : "+id, Toast.LENGTH_LONG).show();
			ModifyDeckActivity.lauchActivity(id, activity);
			
		} catch(DeckBuilderException e) {
			Toast.makeText(activity, "Give a tag !", Toast.LENGTH_LONG).show();
		}
	}

}
